package com.cjyd.hrjb.utils;

import com.cjyd.hrjb.model.dto.ResponseDto;

/**
 * Created fei wo by 2020/4/5
 */
public class ResponseUtil {

    public static <T> ResponseDto<T> success(T data) {
        ResponseDto<T> responseDto = new ResponseDto<>();
        responseDto.setCode(ResultCode.SUCCESS.getCode());
        responseDto.setMsg(ResultCode.SUCCESS.getMsg());
        responseDto.setData(data);
        return responseDto;
    }

    public static ResponseDto<Void> success() {
        return success(null);
    }

    public static ResponseDto<Void> error(ResultCode resultCode) {
        ResponseDto<Void> responseDto = new ResponseDto<>();
        responseDto.setCode(resultCode.getCode());
        responseDto.setMsg(resultCode.getMsg());
        return responseDto;
    }

    public static ResponseDto<Void> sysError() {
        ResponseDto<Void> responseDto = new ResponseDto<>();
        responseDto.setCode(ResultCode.SYSTEM_ERROR.getCode());
        responseDto.setMsg(ResultCode.SYSTEM_ERROR.getMsg());
        return responseDto;
    }
}
